<div class="main clearfix">
    <div class="Tabs clearfix">
        <ul class="clearfix">
            <li><a href="<?php echo Url::createUrl("paymentTotal/index")?>"><span>Tổng</span></a></li>
            <li><a href="<?php echo Url::createUrl("paymentSmsWapmaster/index")?>"><span>SMS</span></a></li>
            <li><a class="active" href="<?php echo Url::createUrl("paymentCardWapmaster/index")?>"><span>CARD</span></a></li>
            <li><a href="<?php echo Url::createUrl("paymentChargingWapmaster/index")?>"><span>CHARGING</span></a></li>
        </ul>                
    </div>
    <div class="box_tab bottom30 clearfix">        
        <div class="Tabs clearfix">
            <ul class="clearfix">
                <li><a href="<?php echo Url::createUrl("paymentCardWapmaster/index")?>"><span>Tài khoản Wapmaster</span></a></li>
                <li><a class="active" href="<?php echo Url::createUrl("paymentCardPartner/index")?>"><span>Nhà phân phối</span></a></li>
                <li><a href="<?php echo Url::createUrl("paymentCardProduct/index")?>"><span>Sản phẩm</span></a></li>            
            </ul>                
        </div>
        <div class="box clearfix">
                         <form action="" method="GET">
                <ul class="form4">
                    <li class="clearfix">
                        <label><strong>Từ ngày </strong>:</label>
                        <div class="filltext">
                            <?php
                                $this->widget(
                                    "zii.widgets.jui.CJuiDatePicker"
                                    , array(
                                        "name"=>"toDate"
                                        , "id"=>"toDate"
                                        , "value"=>$search["toDate"]                                                                
                                        , "options"=> array(
                                            'showAnim' => 'fold'
                                            , 'dateFormat' => 'dd-mm-yy'
                                            , 'changeYear' => 'true'
                                            , 'changeMonth' => 'true'
                                            , 'showOn' => 'both'
                                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                                        )
                                        , 'htmlOptions' => array(
                                            'style' => 'width:170px'
                                            , 'class' => 'form'
                                        )
                                    )
                                );
                            ?>                                       
                            &nbsp;đến ngày &nbsp; 
                            <?php
                                $this->widget(
                                    "zii.widgets.jui.CJuiDatePicker"
                                    , array(
                                        "name"=>"fromDate"
                                        , "id"=>"fromDate"
                                        , "value"=>$search["fromDate"]                                                                
                                        , "options"=> array(
                                            'showAnim' => 'fold'
                                            , 'dateFormat' => 'dd-mm-yy'
                                            , 'changeYear' => 'true'
                                            , 'changeMonth' => 'true'
                                            , 'showOn' => 'both'
                                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                                        )
                                        , 'htmlOptions' => array(
                                            'style' => 'width:170px'
                                            , 'class' => 'form'
                                        )
                                    )
                                );
                            ?>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Từ khóa </strong>:</label>
                        <div class="filltext">
                            <input type="text" name="keyword" style="width:331px;margin-right:28px" value="<?php echo $search["keyword"];?>">
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Loại thẻ </strong>:</label>
                        <div class="filltext">
                            <select style="width:150px;" name="provider_code">
                                <option value=""> Tất cả </option>
                                <?php foreach($providerCode as $row){ ?>
                                <option value="<?php echo $row["provider_code"];?>" <?php if($search["provider_code"]==$row["provider_code"]) echo "selected";?> ><?php echo $row["provider_code"];?></option>
                                <?php }?>
                            </select>    
                            <select style="width:150px;" name="price">
                                <option value=""> Tất cả </option>
                                <option value="5000" <?php if($search["price"]=="5000") echo "selected";?> >5.000</option>
                                <option value="10000" <?php if($search["price"]=="10000") echo "selected";?> >10.000</option>
                                <option value="15000" <?php if($search["price"]=="15000") echo "selected";?> >15.000</option>
                            </select>                    
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Thứ tự sắp xếp </strong>:</label>
                        <div class="filltext">
                            <select style="width:203px;" name="order" id="order">
                                <option value="" >Mặc định</option>                            
                                <option value="1" <?php if($search["order"]==1) echo "selected";?> >Doanh thu Từ Thấp đến Cao</option>                            
                                <option value="2" <?php if($search["order"]==2) echo "selected";?> >Doanh thu Từ Cao đến Thấp</option>                            
                                <option value="3" <?php if($search["order"]==3) echo "selected";?> >Sản lượng Từ Thấp đến Cao</option>                            
                                <option value="4" <?php if($search["order"]==4) echo "selected";?> >Sản lượng Từ Cao đến Thấp</option>                            
                            </select>                
                        </div>
                    </li>
                    <li class="clearfix"><label>&nbsp;</label>
                        <div class="filltext">
                            <input type="submit" value=" Tìm kiếm" class="btn-bigblue"> 
                        </div>
                    </li>

                </ul>
            </form>
        </div>
    </div>
    <div class="box">
        <div class="fillter clearfix">
            <div class="fl">Tìm thấy <strong class="clred"><?php echo $totalPartner;?></strong> kết quả trong <strong class="clred"><?php echo $numberPage;?></strong> trang</div>
            <?php                
                $url = new Url();            
                $current_url = Common::getCurrentUrl();
                $path = strpos($current_url,'?') !==false ? $current_url.'&' : $current_url.'?';
                $path = str_replace("?page=".$currentPage."&","?",$path);
                $path = str_replace("&page=".$currentPage."&","&",$path);
            ?>            
            <div class="fr">
                <a href="#" class="excel"><strong>Xuất ra file excel</strong></a>
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($numberPage, $currentPage, $path);?>
                </ul>
            </div>
        </div>
        <div class="table clearfix">
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr class="bg-grey">
                        <td width="4%" rowspan="2"><strong>STT</strong></td>
                        <td width="10%" rowspan="2"><strong>Nhà phân phối </strong></td>
                        <td colspan="9"><strong>Thẻ cào</strong><strong></strong></td>
                        <td width="8%" rowspan="2"><strong>DT sau Telco</strong></td>                        
                        <td width="8%" rowspan="2"><strong>DT Thành viên</strong> </td>
                        <td width="8%" rowspan="2"><strong>DT mtop</strong></td>
                        <td width="8%" rowspan="2"><strong>DT NSX</strong></td>
                        <td width="8%" rowspan="2"><strong>Chi tiết</strong></td>
                    </tr>
                    <tr class="bg-grey">
                        <td width="6%" class="text-center">Tổng số thẻ</td>
                        <td width="5%" class="text-center">10.000</td>
                        <td width="5%" class="text-center">20.000</td>
                        <td width="5%" class="text-center">30.000</td>
                        <td width="5%" class="text-center">50.000</td>
                        <td width="5%" class="text-center">100.000</td>
                        <td width="5%" class="text-center">200.000</td>
                        <td width="5%" class="text-center">300.000</td>
                        <td width="5%" class="text-center">500.000</td>
                    </tr>
                    <?php 
                    $i = 1;
                    $total_card = 0;                    
                    
                    $total_10000 = 0;
                    $total_20000 = 0;
                    $total_30000 = 0;
                    $total_50000 = 0;
                    
                    $total_100000 = 0;
                    $total_200000 = 0;
                    $total_300000 = 0;
                    $total_500000 = 0;
                    
                    $total_telco = 0;                    
                    $total_wapmaster = 0;
                    $total_mtop = 0;
                    $total_partner = 0;
                    foreach($card as $id=>$row){
                        $total_card += $row["total_card"];                         
                        
                        $total_10000 += $row["10000"];                         
                        $total_20000 += $row["20000"];                         
                        $total_30000 += $row["30000"];                         
                        $total_50000 += $row["50000"];                                                 
                        
                        $total_100000 += $row["100000"];                         
                        $total_200000 += $row["200000"];                         
                        $total_300000 += $row["300000"];                         
                        $total_500000 += $row["500000"];                                                 
                        
                        $total_telco += $row["telco"];                        
                        $total_wapmaster += $row["wapmaster"];
                        $total_mtop += $row["mtop"];
                        $total_partner += $row["partner"];
                    ?>
                    <tr>
                        <td><?php echo $i;?></td>
                        <td><strong><?php echo $row["name"];?></strong></td>
                        <td class="text-center"><?php echo Common::format_price($row["total_card"]);?></td>
                        
                        <td class="text-center"><?php echo Common::format_price($row["10000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["20000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["30000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["50000"]);?></td>
                        
                        <td class="text-center"><?php echo Common::format_price($row["100000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["200000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["300000"]);?></td>
                        <td class="text-center"><?php echo Common::format_price($row["500000"]);?></td>
                           
                        <td class="text-right clred"><?php echo Common::format_price(round($row["telco"]));?></td>                        
                        <td class="text-right clred"><?php echo Common::format_price(round($row["wapmaster"]));?></td>
                        <td class="text-right clred"><?php echo Common::format_price(round($row["mtop"]));?></td>
                        <td class="text-right clred"><?php echo Common::format_price(round($row["partner"]));?></td>
                        <?php
                            $urlDetail = Url::createUrl("paymentCardPartner/detail", array("partnerId"=>$id, "toDate"=>$search["toDate"], "fromDate"=>$search["fromDate"], "provider_code"=>$search["provider_code"], "price"=>$search["price"]));
                            $urlExport = Url::createUrl("paymentCardPartner/export", array("partnerId"=>$id, "toDate"=>$search["toDate"], "fromDate"=>$search["fromDate"]));
                        ?>
                        <td>
                            <a href="<?php echo $urlDetail;?>">[Chi tiết]</a>&nbsp;&nbsp;
                            <a href="<?php echo $urlExport;?>">[Export Excel]</a>&nbsp;&nbsp;
                        </td>
                    </tr>
                    <?php 
                        $i++;
                    }
                    ?>
                    
                    <tr>
                        <td colspan="2"><strong class="clred">Tổng doanh thu</strong></td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_card);?></strong></td>
                        
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_10000);?></strong></td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_20000);?></strong> </td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_30000);?></strong> </td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_50000);?></strong> </td>
                        
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_100000);?></strong></td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_200000);?></strong> </td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_300000);?></strong> </td>
                        <td class="text-center"><strong class="clred"><?php echo Common::format_price($total_500000);?></strong> </td>
                        
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_telco));?></strong></td>                        
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_wapmaster));?></strong></td>
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_mtop));?></strong></td>
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_partner));?></strong></td>
                        <td class="text-right"></td>
                    </tr>
                    
                </tbody>
            </table>
        </div>
        <div class="fillter clearfix">
            <div class="fr">
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($numberPage, $currentPage, $path);?>
                </ul>
            </div>
        </div>

    </div>
</div>